﻿using System.Windows.Media;
using System.Windows.Shapes;
using FreeGoo.GameEngine.Renderables;
using FreeGoo.WpfRenderer.Constants;

namespace FreeGoo.WpfRenderer
{
    public class PolygonRenderer : RendererWithCanvas
    {
        public PolygonRenderer(RendererFactory factory, BodyRenderable bodyRenderable)
            : base(factory, bodyRenderable)
        {
            Polygon = RendererFactory.CreatePolygonFromGeom(bodyRenderable.Geom);
            SetCanvasContent(Polygon);
            StateChanged();
        }

        public Polygon Polygon { get; set; }

        public override void StateChanged()
        {            
            if (Renderable is BodyRenderable)
            {
                if ((Renderable as BodyRenderable).IsDeadly)
                {
                    Polygon.Fill = BrushConstants.Red;
                }
                else
                {
                    Polygon.Fill = BrushConstants.DarkGray;
                }

                Polygon.StrokeThickness = 0;
            }            
        }
    }
}
